import 'package:flutter/material.dart';
import '../../widgets/inputWidget.dart';
import '../helper/global_config.dart';
import '../widgets/someCards.dart';

import 'Helper.dart';

class MenuHelper {
  static Widget menuCard() {
    return new Container(
      color: GlobalConfig.cardBackgroundColor,
      margin: const EdgeInsets.only(top: 6.0, bottom: 6.0),
      padding: const EdgeInsets.only(top: 12.0, bottom: 8.0),
      child: new Row(
        mainAxisAlignment: MainAxisAlignment.start,
        children: <Widget>[],
      ),
    );
  }



  static Widget getEmptyMenu() {
    return new Container(
    );
  }

  static List<Widget> menuPanel(String title,List<Widget> wList, int col,{double fSize=16.0}) {
    List<Widget>  result = [];
    int n = 0;
    List<Widget>  xx = [];
    if(title!=null)
       result.add(Container(
          padding: EdgeInsets.all(fSize),
          child:Text(title,style: TextStyle(fontSize: fSize))));
    for (var item in wList) {
      if (n == col) {
        result.add(getMenuRow(xx,col));
        n = 0;
        xx = [];
      }

      xx.add(item);
      n++;
    }
    result.add(getMenuRow(xx,col));

    return result;
  }

  static Widget getMenuRowList(List<Widget> wList,int col) {
    List<Widget>  result = [];
    int n = 0;
    List<Widget>  xx = [];
   
    for (var item in wList) {
      if (n == col) {
        result.add(getMenuRow(xx,col));
        n = 0;
        xx = [];
      }

      xx.add(item);
      n++;
    }
    result.add(getMenuRow(xx,col));

    return Column(children:result,);
  }

  static Widget getMenuRow(List<Widget> wList,int col) {
    while(wList.length<col){
        wList.add(getEmptyMenu());
    }
    return InputWidget.getShowRow(wList, false);
  }

  static Widget getMenuCard(String title,List<Widget> wList) {
    return SomeCard.inCard2(
          Container(
            color: GlobalConfig.cardBackgroundColor,
            child: Column(
             crossAxisAlignment: CrossAxisAlignment.start,
             children: menuPanel(title,wList, 4)),
          margin: EdgeInsets.only(bottom:8.0),
             )
        );
  }


}
